﻿using SharpKit.JavaScript;

namespace SharpKit.Rx.Demo
{
	[JsType(JsMode.Prototype, Filename = "Console.js")]
	public class Console : jQuery.jQueryContext
	{
		private static jQuery.jQuery _result;

		public static jQuery.jQuery ResultElement
		{
			get
			{
				if (!_result.As<bool>())
				{
					_result = J("#result");
					if (_result.size() < 0)
						_result = J("<div/>").appendTo(document.body);
				}
				return _result;
			}
			set { _result = value; }
		}

		public static void WriteLine(string data)
		{
			ResultElement.append(J("<p/>").text(data));
		}

		public static void WriteHeader(string title)
		{
			ResultElement.append(J("<h3/>").text(title));
		}

		public static void Clear()
		{
			ResultElement.empty();
		}
	}
}